package net.cyndeline.itemEventFactory

import net.cyndeline.entitySystem.EntityRef
import net.cyndeline.entitySystem.Event

/**
 * Contains the result of requesting events to send to a list of targets.
 * This container is used to minimize the amount of method signatures that
 * needs to be changed should the result content change in the future.
 */
trait ActionResult {
  
  /**
   * @return A list of entities mapped to the events that should be
   * 		 sent to them.
   */
  def events: List[(EntityRef, List[Event])]
}

/**
 * Provides data-setters to be used only when constructing the result.
 */
trait ActionResultConfig extends ActionResult {
  
  /**
   * Stores an event to be sent to a target. Subsequent events are stored in
   * the order they're added.
   */
  def addEvent(target: EntityRef, event: Event)
  
  /**
   * Adds a list of events.
   */
  def addEvent(target: EntityRef, events: List[Event]) {
    for (event <- events) {
      addEvent(target, event)
    }
  }
}